# -*- coding: utf-8 -*-
# @Author: QX
# @File: shoptuload.py
import jsonpath
import requests
print('============登录============')
url='http://novel.hctestedu.com/user/login'
data={'username':'13311110005',
      'password':'123456'}
r=requests.post(url=url,data=data)
print(r.json())
token=jsonpath.jsonpath(r.json(), '$..token')[0]
print(token)
print('=============应用上面的token产生图片的位置===========')
url='http://novel.hctestedu.com/file/picUpload'
file={'file':('3.jpg',open(r'D:\图片\4.jpg','rb'),'image/jpg')}
headers={'Authorization':token}
r=requests.post(url=url,headers=headers,files=file)
print(r.json())
userphoto=jsonpath.jsonpath(r.json(), '$..data')[0]
print('=========利用token和图片确定后上传成功===============')
url='http://novel.hctestedu.com/user/updateUserInfo'
headers={'Authorization':token}
data={'userPhoto':userphoto}
r=requests.post(url=url,data=data,headers=headers)
print(r.json())
